<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://micronova.com/yuzu" prefix="m"%> 
<%@page import = "com.db4o.ext.ExtObjectContainer" %>
<%@page import = "com.db4o.servlet.Db4oServlet" %>
<%@page import = "facades.*" %>
<%@page import = "auser.*" %>
<%@page import = "java.util.*" %>
<c:if test="${empty editSocio}"><c:redirect url="/app/start/index.jsp" /> </c:if>
<% SessionFacade sfacade = new SessionFacade(session); %>

<% Socio soc = (Socio) session.getAttribute("editSocio"); %>
<% soc.resetBooleans(); %>
<% Map prop = new java.util.Hashtable(request.getParameterMap()); %> 
<% sfacade.setSessionBean("editSocio",prop); %>

<c:set var='valid' value='${true}' />

<c:if test="${empty param.cognome}">
	<c:set var='eCognome' value='necessario'  scope='request'/>
	<c:set var='valid' value='${false}' />
</c:if>

<c:if test="${empty param.nome}">
	<c:set var='eNome' value='necessario'  scope='request'/>
	<c:set var='valid' value='${false}' />
</c:if>

<c:if test="${valid}">
	<% 
		if(soc.getPrimaTessera()!=null){
			if(soc.getPrimaTessera().getAnnoCompetenza()==0 && soc.getPrimaTessera().getNumeroTessera()==0 ){
				soc.getPrimaTessera().setSocio(null);
				soc.setPrimaTessera(null);
				soc.resetUltimaTessera();
			}else{
				if(request.getParameter("EditMode").equals("ADD")){
					sfacade.saveScritturaSoci(soc.getPrimaTessera()); 
				}
			}
		}
		sfacade.setFromSession("editSocio",true); 
	%> 
	<c:redirect url="/app/start/index.jsp" />
</c:if>

<c:forEach items="${param}" var="para">
	${para} <br>
</c:forEach>
<c:if test="${!valid}">
	<jsp:forward page="edit.jsp" />
</c:if>